package com.weaponlin.stream;

import com.google.common.collect.Lists;
import com.weaponlin.entity.Person;

import java.util.ArrayList;
import java.util.List;

import static java.util.stream.Collectors.toList;

public class Test1 {
    public static void main(String[] args) {
        ArrayList<Person> list = Lists.newArrayList(
                new Person().setAge(19),
                new Person().setAge(20),
                new Person().setAge(21),
                new Person().setAge(22)
        );
        System.out.println(list);
        list.forEach(e -> e.setAge(e.getAge() + 1));
        System.out.println(list);
        list.stream().forEach(e -> e.setAge(e.getAge() + 1));
        System.out.println(list);
        List<Person> mappedPerson = list.stream().map(e -> e.setAge(e.getAge() + 1)).collect(toList());
        System.out.println(list);
        System.out.println(mappedPerson);
    }
}
